﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace BRS.BidModule
{
    public partial class Rightfrm : Form
    {
        Entities brs = new Entities();
        public Rightfrm()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if ((textBox1.Text != "" && textBox1.Text != null))// && (textBox2.Text != "" && textBox2.Text != null) && (textBox3.Text != "" && textBox3.Text != null) && (textBox4.Text != "" && textBox4.Text != null)
            {
                Rights right = new Rights()
                {
                    Name = textBox1.Text,
                    Module = textBox2.Text,
                    Frm = textBox3.Text,
                    btn = textBox4.Text

                };
                if (brs.Rights.Where(p => (p.Name == right.Name) || (p.Module == right.Module)).Count() > 0)
                {
                    MessageBox.Show("已经存在此权限！");
                }
                else
                {
                    brs.Rights.Add(right);
                    var ok = brs.SaveChanges();
                    if (ok == 1) MessageBox.Show("添加成功！");
                }


            }
        }
    }
}
